/*
+----------------------------------------------------------------------+
| MD                                                              |
+----------------------------------------------------------------------+
| This source file is subject to version 2.0 of the Apache license,    |
| that is bundled with this package in the file LICENSE, and is        |
| available through the world-wide-web at the following url:           |
| http://www.apache.org/licenses/LICENSE-2.0.html                      |
| If you did not receive a copy of the Apache2.0 license and are unable|
| to obtain it through the world-wide-web, please send a note to       |
| license@php.net so we can mail you a copy immediately.               |
+----------------------------------------------------------------------+
| Author: vb2005xu  <vb2005xu@qq.com>                                  |
+----------------------------------------------------------------------+
*/

#ifndef _MD_H_
#define _MD_H_

#include "php.h"
#include "php_ini.h"
#include "main/php_main.h"
#include "zend_extensions.h"
#include "zend_exceptions.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "ext/date/php_date.h"
#include "php7_wrapper.h"

#if PHP_VERSION_ID >= 70000
#include "zend_smart_str.h"
#else
#include "ext/standard/php_smart_str.h"
#endif

#include <stdlib.h>

#define MD_RES_NAME                    "MD"
#define MD_AUTHOR                      "vb2005xu  [ vb2005xu@qq.com ]"
#define MD_VERSION                     "0.1.0"
#define MD_SUPPORTS                    "https://gitee.com/amlove2/y-php-extends"

/*
定义数组内存释放函数

zval_ptr_dtor 用于清理分配给变量的内存
当在用户空间代码中调用unset($a)时候，Zend Engine会在那个变量上执行zval_ptr_dtor()
它实际做的事情是减少它的refcount
ZVAL_NULL 参见: Zend/zend_types.h
*/
#if PHP_VERSION_ID >= 70000

#define EX_ARRAY_DESTROY(arr) \
	do { \
		zval_ptr_dtor(arr); \
		ZVAL_NULL(arr); \
	} while(0)

#else

#define EX_ARRAY_DESTROY(arr) \
	do { \
		zval_ptr_dtor(arr);\
	} while(0)

#endif


#endif /* _MD_H_ */
